import request from "@/router/axios";

/**
 * @param current 当前页
 * @param size 每页数据量
 * @returns {AxiosPromise}
 */
export const getParentList = params => {
  return request({
    url: "/api/hg-quality/rule/quality-rule/page",
    method: "get",
    params
  });
};

export const getChildList = (current, size, ruleId, params) => {
  return request({
    url: "/api/hg-quality/rule/quality-rule-item/page",
    method: "get",
    params: {
      ...params,
      ruleId,
      current,
      size
    }
  });
};

export const add = row => {
  return request({
    url: "/api/hg-quality/rule/quality-rule/add",
    method: "post",
    data: row
  });
};

export const update = row => {
  return request({
    url: "/api/hg-quality/rule/quality-rule/update",
    method: "post",
    data: row
  });
};

export const copy = data => {
  return request({
    url: "/api/hg-quality/rule/quality-rule/copy",
    method: "post",
    data
  });
};

export const remove = ids => {
  return request({
    url: "/api/hg-quality/rule/quality-rule/remove",
    method: "delete",
    params: {
      ids
    }
  });
};

export const unbind = ids => {
  return request({
    url: "/api/hg-quality/rule/quality-rule-material/remove",
    method: "delete",
    params: {
      ids
    }
  });
};

export const getMaterialList = (current, size, data) => {
  return request({
    url: "/api/hg-public/material/info/page",
    method: "get",
    params: {
      ...data,
      current,
      size
    }
  });
};
export const getMaterialList2 = (current, size, data) => {
  return request({
    url: "/api/hg-public/material/info/page2",
    method: "get",
    params: {
      ...data,
      current,
      size
    }
  });
};

export const addList = data => {
  return request({
    url: "/api/hg-quality/rule/quality-rule-material/add",
    method: "post",
    data: data
  });
};

export const getChildMaterialList = (current, size, ruleCode) => {
  return request({
    url: "/api/hg-quality/rule/quality-rule-material/page",
    method: "get",
    params: {
      ruleCode,
      current,
      size
    }
  });
};
export const getBusinessTypeList = () => {
  return request({
    url: "/api/hg-public/procedure/list",
    method: "get",
    params: {
    }
  });
};
export const getCategoryList = () => {
  return request({
    url: "/api/blade-system/dict-biz/dictionary?code=quality_rule_category",
    method: "get",
    params: {
    }
  });
};
